home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 23 / CU Amiga - Super CD-ROM 23 (June 1998).iso / CUCD / Programming / OUI / rcs / window.cc < prev   
Encoding:
C/C++ Source or Header  |  1998-04-08  |  23.9 KB  |  1,101 lines

  1. head    1.5;
  2. access;
  3. symbols;
  4. locks
  5.     dlorre:1.5; strict;
  6. comment    @// @;
  7.  
  8.  
  9. 1.5
  10. date    98.01.13.19.55.59;    author dlorre;    state Exp;
  11. branches;
  12. next    1.4;
  13.  
  14. 1.4
  15. date    97.09.17.08.16.56;    author dlorre;    state Exp;
  16. branches;
  17. next    1.3;
  18.  
  19. 1.3
  20. date    97.07.14.04.21.30;    author dlorre;    state Exp;
  21. branches;
  22. next    1.2;
  23.  
  24. 1.2
  25. date    96.08.28.20.07.00;    author dlorre;    state Exp;
  26. branches;
  27. next    1.1;
  28.  
  29. 1.1
  30. date    96.08.22.02.05.10;    author dlorre;    state Exp;
  31. branches;
  32. next    ;
  33.  
  34.  
  35. desc
  36. @Oui.lib -- Object User Interface
  37. Projet créé en 1994
  38. Auteur: Dominique Lorre
  39. @
  40.  
  41.  
  42. 1.5
  43. log
  44. @now use winlist
  45. @
  46. text
  47. @// $Id: window.cc 1.4 1997/09/17 08:16:56 dlorre Exp $
  48. #include <exec/types.h>
  49. #include <graphics/gfxbase.h>
  50. #include <graphics/gfxmacros.h>
  51. #include <intuition/gadgetclass.h>
  52. #include <libraries/gadtools.h>
  53. #include <stdio.h>
  54. #include <string.h>
  55. #include <mydebug.h>
  56.  
  57. #include "screen.h"
  58. #include "window.h"
  59. #include "locale.h"
  60. #include "gadgetlist.h"
  61. #include "gadgets/gadget.h"
  62. #include "gadgets/string.h"
  63. #include "gadgets/fbutton.h"
  64.  
  65. #include <proto/exec.h>
  66. #include <proto/graphics.h>
  67. #include <proto/layers.h>
  68. #include <proto/intuition.h>
  69. #include <proto/gadtools.h>
  70. #include <proto/utility.h>
  71. #include "compiler.h"
  72.  
  73. catalog  *ocat ;
  74. slist    *winlist ;
  75.  
  76. extern "C" {
  77. extern struct LocaleBase *LocaleBase ;
  78.  
  79. void _STI_4500_initouicat()
  80. {
  81.     ocat = new catalog("oui.catalog", "english", NULL) ;
  82. }
  83.  
  84. void _STD_4500_closeouicat()
  85. {
  86.     delete ocat ;
  87. }
  88.  
  89. void _STI_4500_initwinlist()
  90. {
  91.     winlist = new slist ;
  92. }
  93.  
  94. void _STD_4500_closewinlist()
  95. {
  96.     delete winlist ;
  97. }
  98. }
  99.  
  100. lstring  FAR ok NPARMS(ocat, "_Ok", "MSG_OK_GAD", 1) ;
  101. lstring  FAR cancel LPARMS(ocat, "_Cancel", "MSG_CANCEL_GAD") ;
  102. lstring  FAR parent LPARMS(ocat, "_Parent", "MSG_PARENT_GAD") ;
  103. lstring  FAR drawer LPARMS(ocat, "_Drawer:", "MSG_DRAWER_GAD") ;
  104. lstring  FAR file LPARMS(ocat, "_File:", "MSG_FILE_GAD") ;
  105. lstring  FAR comment LPARMS(ocat, "Co_mment:", "MSG_COMMENT_GAD") ;
  106.  
  107.  
  108. // Constructor
  109. // Initialisation of variables in a predefined state.
  110. window::window(short l, short t, short w, short h) : rectangle(l, t, w, h),
  111.                         ws(NULL),
  112.                         win(NULL),
  113.                         mp(NULL),
  114.                         idcmp(NULL),
  115.                         hasgadgets(FALSE),
  116.                         hasmenus(FALSE),
  117.                         active(FALSE),
  118.                         initok(FALSE),
  119.                         okflag(FALSE),
  120.                         g(NULL),
  121.                         rp(NULL),
  122.                         signal(NULL),
  123.                         reqfunc(NULL),
  124.                         tags(NULL),
  125.                         bgrp(NULL),
  126.                         bgbm(NULL),
  127.                         emode(0)
  128. {
  129.     link.win = this ;
  130.     winlist->addtail(&link) ;
  131. }
  132.  
  133.  
  134. window::~window()
  135. {
  136.     if (initok) close() ;
  137.     winlist->remove(&link) ;
  138. }
  139.  
  140.  
  141. // _open -- parameter list version
  142. // calls same function with arrays
  143. void window::_open(MsgPort *wp, ULONG iflags, ULONG data, ...)
  144. {
  145.     _open(wp, iflags, (TagItem *)&data) ;
  146. }
  147.  
  148. // _open -- var-array version
  149. // Calls OpenWindow, copy tags if any
  150. void __saveds window::_open(MsgPort *wp, ULONG iflags, TagItem *t)
  151. {
  152.     tags = CloneTagItems(t) ; // A NULL result in cloning tags is tolerated
  153.                               // Because either the window should fail or
  154.                               // the parameter passed is already NULL.
  155.                               // In other terms, the window will open
  156.                               // with default parameters if enough memory.
  157.     mp = wp ;
  158.  
  159.     // IDCMP_REFRESH...  obligatoire : il ne sera délivré aucun passe-droit.
  160.     idcmp = iflags | IDCMP_REFRESHWINDOW ;
  161.  
  162.     initok = active = FALSE ;
  163.     selfmsg = BOOL(!mp) ;
  164.     win = OpenWindowTags(NULL,
  165.         WA_Left,        left,
  166.         WA_Top,         top,
  167.         WA_InnerWidth,  width,
  168.         WA_InnerHeight, height,
  169.         WA_AutoAdjust,  TRUE,
  170.         WA_CustomScreen, (LONG)ws->scr,
  171.         TAG_MORE,       tags) ; // TAG_MORE is a terminaison point
  172.                                 // i.e. no TAG_DONE necessary.
  173.  
  174.     if (win) {
  175.         active = initok = TRUE ;
  176.         win->UserData = (BYTE *)this ;  // User data contains object pointer
  177.         rp = win->RPort ;
  178.         if (!selfmsg) win->UserPort = mp ;  // Shared message port
  179.         if (ModifyIDCMP(win, idcmp)) {      // idcmp is never NULL (refresh at least)
  180.             mp = win->UserPort ;
  181.             signal = 1 << mp->mp_SigBit ;
  182.         }
  183.         else {  // This is probably a signal allocation failure, try to free some
  184.             CloseWindow(win) ;
  185.             win = NULL ;
  186.             active = initok = FALSE ;
  187.         }
  188.     }
  189. }
  190.  
  191. void window::open(screen *nws)
  192. {
  193.     ws = nws ;
  194.     _open(NULL, IDCMP_CLOSEWINDOW,
  195.         WA_CloseGadget, TRUE,
  196.         TAG_DONE) ;
  197. }
  198.  
  199. void window::close()
  200. {
  201. Menu    *m ;
  202.  
  203.                     // initok indique que TOUTES les opérations à
  204.     if (initok) {   // l'initialisation ont réussi
  205.         if (tags) FreeTagItems(tags) ;
  206.         if (win) {
  207.             strip();
  208.             if (hasmenus) {
  209.                 ClearMenuStrip(win) ;
  210.                 while (menu) {
  211.                     m = menu->NextMenu ;
  212.                     FreeMenus(menu) ;
  213.                     menu = m ;
  214.                 }
  215.                 hasmenus = FALSE ;
  216.             }
  217.             CloseWindow(win) ;
  218.             if (hasgadgets) {
  219.                 delete g ;
  220.                 g = NULL ;
  221.                 hasgadgets = FALSE ;
  222.             }
  223.             win = NULL ;
  224.         }
  225.     }
  226.     initok = active = FALSE ;
  227. }
  228.  
  229.  
  230. void window::strip()
  231. {
  232.     Forbid();
  233.     stripimsg() ;
  234.     if (!selfmsg)
  235.         win->UserPort = NULL;
  236.     ModifyIDCMP(win, NULL);
  237.     Permit();
  238. }
  239.  
  240.  
  241. void window::stripimsg()
  242. {
  243. IntuiMessage *msg;
  244. Node *succ;
  245.  
  246.     msg = (IntuiMessage *) mp->mp_MsgList.lh_Head;
  247.  
  248.     while( succ =  msg->ExecMessage.mn_Node.ln_Succ ) {
  249.  
  250.         if( msg->IDCMPWindow ==  win ) {
  251.  
  252.             /* Intuition is about to free this message.
  253.              * Make sure that we have politely sent it back.
  254.              */
  255.             Remove( (Node *)msg );
  256.  
  257.             ReplyMsg( (Message *)msg );
  258.         }
  259.  
  260.         msg = (IntuiMessage *) succ;
  261.     }
  262. }
  263.  
  264.  
  265. void window::eventloop()
  266. {
  267. IntuiMessage *msg ;
  268.  
  269.     if (initok) {
  270.         while (active) {
  271.             Wait(signal) ;
  272.             while (msg = (IntuiMessage *)GetMsg(win->UserPort)) {
  273.                 processevents(msg) ;
  274.                 ReplyMsg((Message *)msg) ;
  275.             }
  276.         }
  277.     }
  278. }
  279.  
  280. void window::processevents(IntuiMessage *msg)
  281. {
  282. IntuiMessage    *gt_msg, smsg ;
  283. BOOL            doevents ;
  284. static Gadget   *curgad = NULL ;
  285. static ULONG    curattr ;
  286.  
  287.     gt_msg = NULL ;
  288.     doevents = FALSE ;
  289.     if (msg->Class & (IDCMP_MOUSEMOVE|IDCMP_GADGETUP|IDCMP_GADGETDOWN)) {
  290.         switch(msg->Class) {
  291.         case IDCMP_GADGETDOWN:
  292.             curgad = (Gadget *)msg->IAddress ;
  293.             curattr = ULONG(curgad->UserData) ;
  294.             if (!curattr) gt_msg = GT_FilterIMsg(msg) ;
  295.             break ;
  296.         case IDCMP_GADGETUP:
  297.             curgad = NULL ;
  298.             gt_msg = GT_FilterIMsg(msg) ;
  299.             break ;
  300.         case IDCMP_MOUSEMOVE:
  301.             if (curgad && curattr) {
  302.             ULONG code, res ;
  303.                 msg->IAddress = curgad ;
  304.                 res = GetAttr(curattr, curgad, &code) ;
  305.                 msg->Code = USHORT(res) ;
  306.                 doevents = TRUE ;
  307.             }
  308.             else {
  309.                 gt_msg = GT_FilterIMsg(msg) ;
  310.             }
  311.             break ;
  312.         }
  313.     }
  314.     else {
  315.         gt_msg = GT_FilterIMsg(msg) ;
  316.     }
  317.  
  318.  
  319.     if (doevents || gt_msg) {
  320.         doevents = TRUE ;
  321.         smsg = (gt_msg)?*gt_msg:*msg ;
  322.     }
  323.     GT_PostFilterIMsg(gt_msg) ;
  324.     if (doevents) simpleevent(&smsg) ;
  325. }
  326.  
  327. void window::simpleevent(IntuiMessage *msg)
  328. {
  329. MenuItem *item ;
  330. void (*menufunc)() ;
  331. TagItem *tags ;
  332. unsigned long id, classe ;
  333. USHORT code ;
  334. Gadget *gad ;
  335. gadget *gd ;
  336.  
  337.     code = msg->Code ;
  338.     classe = msg->Class ;
  339.     gad = (Gadget *)msg->IAddress ;
  340.     switch (classe) {
  341.         case IDCMP_CLOSEWINDOW:
  342.             active = FALSE ;
  343.             break ;
  344.         case IDCMP_MENUPICK:
  345.             if (hasmenus) {
  346.                 while (code != MENUNULL) {
  347.                     item = ItemAddress(menu, code);
  348.                     menufunc = (void (*)())GTMENUITEM_USERDATA(item);
  349.                     if (menufunc) {
  350.                         menufunc();
  351.                     }
  352.                     code = item->NextSelect;
  353.                 }
  354.             }
  355.             break ;
  356.         case IDCMP_IDCMPUPDATE:
  357.             tags = (TagItem *)gad ;
  358.             id = GetTagData(GA_ID, 0, tags) ;
  359.             gd = g->getgadget(id) ;
  360.             code = (unsigned short)GetTagData(ULONG(gd->gad->UserData), 0, tags) ;
  361.             g->processgadget(id, classe, code) ;
  362.             break ;
  363.         case IDCMP_GADGETUP:
  364.         case IDCMP_GADGETDOWN:
  365.         case IDCMP_MOUSEMOVE:
  366.             if (hasgadgets) {
  367.                 g->processgadget(gad->GadgetID, classe, code) ;
  368.             }
  369.             else if (gad->GadgetType & GTYP_REQGADGET)
  370.                 if (reqfunc) reqfunc(gad->GadgetID, classe, code) ;
  371.             break ;
  372.         case IDCMP_REFRESHWINDOW:
  373.             GT_BeginRefresh(win) ;
  374.             GT_EndRefresh(win, TRUE) ;
  375.             break ;
  376.         case IDCMP_VANILLAKEY:
  377.             handlevkey(code) ;
  378.             break ;
  379.         case IDCMP_RAWKEY:
  380.             handlerawkey(code) ;
  381.             break ;
  382.         case IDCMP_MOUSEBUTTONS:
  383.             handlemousebuttons(code, msg->MouseX, msg->MouseY, msg->Qualifier) ;
  384.             break ;
  385.     }
  386. }
  387.  
  388.  
  389. void window::setmenus(NewMenu *menu1, ...)
  390. {
  391. NewMenu **pmenu ;
  392. NewMenu *cmenu ;
  393. Menu *m, *pm ;
  394.  
  395.     menu = pm = NULL ;
  396.     pmenu = &menu1 ;
  397.     cmenu = *pmenu++ ;
  398.     while (cmenu) {
  399.         m = CreateMenus(cmenu,
  400.             TAG_DONE) ;
  401.         if (pm) {
  402.             pm->NextMenu = m ;
  403.             pm = m ;
  404.         }
  405.         else {
  406.             menu = pm = m ;
  407.         }
  408.         cmenu = *pmenu++ ;
  409.     }
  410.     LayoutMenus(menu, ws->vi,
  411.         GTMN_NewLookMenus,  TRUE,
  412.         TAG_DONE) ;
  413.  
  414.     SetMenuStrip(win, menu) ;
  415.     hasmenus = TRUE ;
  416. }
  417.  
  418.  
  419. void window::expandmenu(Menu *curm, NewMenu *extmenu)
  420. {
  421. Menu *sm, *pm, *nm ;
  422.  
  423.     if (!menu)                  // no menus ?
  424.         return ;
  425.  
  426.     sm = curm->NextMenu ;
  427.     if (curm == menu)
  428.         pm = NULL ;
  429.     else {
  430.         pm = menu ;
  431.         while (pm->NextMenu && pm->NextMenu != curm)
  432.             pm = pm->NextMenu ;
  433.     }
  434.  
  435.     nm = CreateMenus(extmenu,
  436.                 TAG_DONE) ;
  437.  
  438.     if (nm) {
  439.         ClearMenuStrip(win) ;
  440.         nm->NextMenu = sm ;
  441.         if (pm) pm->NextMenu = nm ;
  442.         LayoutMenus(menu, ws->vi,
  443.             GTMN_NewLookMenus, TRUE,
  444.             TAG_DONE) ;
  445.         SetMenuStrip(win, menu) ;
  446.         curm->NextMenu = NULL ;
  447.         FreeMenus(curm) ;
  448.     }
  449. }
  450.  
  451. void window::menuchanges(menustate *ms, LONG count)
  452. {
  453. long i ;
  454.  
  455.     ClearMenuStrip(win) ;
  456.     for (i=0; i<count; i++) {
  457.  
  458.         if (ms[i].checked)
  459.             ms[i].item->Flags |=  CHECKED ;
  460.         else
  461.             ms[i].item->Flags &= ~CHECKED ;
  462.  
  463.         if (ms[i].enable)
  464.             ms[i].item->Flags |=  ITEMENABLED ;
  465.         else
  466.             ms[i].item->Flags &=  ~ITEMENABLED ;
  467.  
  468.     }
  469.     ResetMenuStrip(win, menu) ;
  470. }
  471.  
  472.  
  473. short window::initarea(short w, short h, int size)
  474. {
  475. short retval = TRUE ;
  476.  
  477.     if (areaBuffer = new WORD[size]) {
  478.         if (areaInfo = new AreaInfo) {
  479.             if (tmpRas = new TmpRas) {
  480.                 if (GfxBase->LibNode.lib_Version >= 39) {
  481.                     tmpBitMap = AllocBitMap(w, h, 1,
  482.                         BMF_CLEAR|BMF_INTERLEAVED|BMF_DISPLAYABLE, ws->scr->RastPort.BitMap) ;
  483.                     if (!tmpBitMap)
  484.                         retval = FALSE ;
  485.                     else {
  486.                         tmpBuffer = tmpBitMap->Planes[0] ;
  487.                         InitTmpRas(tmpRas, tmpBuffer, tmpBitMap->BytesPerRow * h);
  488.                     }
  489.                 }
  490.                 else {
  491.                     tmpBuffer = (PLANEPTR)AllocRaster(w, h);
  492.                     if (!tmpBuffer)
  493.                         retval = FALSE ;
  494.                     else
  495.                         InitTmpRas(tmpRas, tmpBuffer, RASSIZE(w, h));
  496.                 }
  497.  
  498.                 if (retval) {
  499.                     InitArea(areaInfo, areaBuffer, (size*2)/5);
  500.                     awidth = w ;
  501.                     aheight = h ;
  502.                     asize = size ;
  503.                     rp->AreaInfo = areaInfo;
  504.                     rp->TmpRas = tmpRas;
  505.                 }
  506.             }
  507.         }
  508.     }
  509.     if (!retval) freearea() ;
  510.     return retval ;
  511. }
  512.  
  513. void window::freearea()
  514. {
  515.  
  516.     if (GfxBase->LibNode.lib_Version >= 39) {
  517.         if (tmpBitMap) FreeBitMap(tmpBitMap) ;
  518.     }
  519.     else
  520.         if (tmpBuffer) FreeRaster(tmpBuffer, awidth, aheight);
  521.     tmpBitMap = NULL ;
  522.     tmpBuffer = NULL ;
  523.  
  524.     if (tmpRas) {
  525.         delete tmpRas ;
  526.         tmpRas = NULL ;
  527.     }
  528.     if (areaInfo) {
  529.         delete areaInfo ;
  530.         areaInfo = NULL ;
  531.     }
  532.     if (areaBuffer) {
  533.         delete [] areaBuffer ;
  534.         areaBuffer = NULL ;
  535.     }
  536.  
  537. }
  538.  
  539.  
  540. void window::prepbox(BOOL center)
  541. {
  542. long mw = g->lmax(ok, cancel, NULL) + 20 ;
  543.  
  544.     g->box( ws->scr->WBorLeft+20,
  545.             g->maxh+8,
  546.             mw,
  547.             g->fontheight*3/2) ;
  548.  
  549.     g->setgpen(ws->xpens[GREEN_PEN]) ;
  550.     new fbutton(g, WFUNC(&window::fok), ok, TRUE) ;
  551.  
  552.     g->move(g->maxw-g->left-mw) ;
  553.     g->setgpen(ws->xpens[RED_PEN]) ;
  554.     new fbutton(g, WFUNC(&window::fcancel), cancel, FALSE) ;
  555.  
  556.  
  557.     width = short(g->maxw-ws->scr->WBorLeft+20) ;
  558.     height = short(g->maxh-ws->winbarheight+8) ;
  559.  
  560.     if (center) {
  561.         left = short((ws->width - width - ws->scr->WBorLeft-ws->scr->WBorRight) / 2) ;
  562.         top = short((ws->height - height - ws->winbarheight - ws->scr->WBorBottom) / 2) ;
  563.     }
  564.  
  565. }
  566.  
  567. void window::move(short dx, short dy)
  568. {
  569.     rectangle::move(dx, dy) ;
  570.     if (win) ChangeWindowBox(win, left, top, width, height) ;
  571. }
  572.  
  573. void window::size(short dw, short dh)
  574. {
  575.     rectangle::size(dw, dh) ;
  576.     if (win) ChangeWindowBox(win, left, top, width, height) ;
  577. }
  578.  
  579. void window::box(short x, short y, short w, short h)
  580. {
  581.     rectangle::box(x, y, w, h) ;
  582.     if (win) ChangeWindowBox(win, left, top, width, height) ;
  583. }
  584.  
  585. void window::limits(short wmin, short hmin, short wmax, short hmax)
  586. {
  587.     rectangle::limits(wmin, hmin, wmax, hmax) ;
  588.     if (win) WindowLimits(win, minw, minh, maxw, maxh) ;
  589. }
  590. void window::pmove(long x, long y)                     // Move(rp, ...)
  591. {
  592.     Move(rp, x, y) ;
  593. }
  594.  
  595. void window::text( const char *string, unsigned long count )
  596. {
  597.     Text(rp, STRPTR(string), count) ;
  598. }
  599.  
  600. void window::otext( long x, long y, const char *string )
  601. {
  602.     pmove(x, y) ;
  603.     text(string, strlen(string)) ;
  604. }
  605.  
  606. void window::fname(gadget *g, unsigned long classe, unsigned short code)
  607. {
  608.     strcpy(sname, ((string *)g)->curstring) ;
  609. }
  610.  
  611. #if defined( __GNUG__ )
  612. ADD2INIT(_STI_4500_initouicat, -40);
  613. ADD2INIT(_STI_4500_initwinlist, -40);
  614. ADD2EXIT(_STD_4500_closeouicat,-40);
  615. ADD2EXIT(_STD_4500_closewinlist,-40);
  616. #endif
  617. @
  618.  
  619.  
  620. 1.4
  621. log
  622. @*** empty log message ***
  623. @
  624. text
  625. @d1 1
  626. a1 1
  627. // $Id: window.cc 1.3 1997/07/14 04:21:30 dlorre Exp dlorre $
  628. d28 1
  629. d42 10
  630. d83 9
  631. d94 1
  632. d336 3
  633. d429 1
  634. a429 1
  635. short retval = FALSE ;
  636. d434 10
  637. a443 3
  638.                 tmpBuffer = (UBYTE *)AllocRaster( w, h ) ;
  639.                 if (!tmpBuffer)
  640.                     retval = FALSE ;
  641. d445 8
  642. a453 4
  643.  
  644.                    // docs say don't use RASSIZE in V39 but I don't know yet
  645.                    // another way of doing this
  646.                     InitTmpRas(tmpRas, tmpBuffer, RASSIZE( w, h )) ;
  647. a458 1
  648.                     retval = TRUE ;
  649. d469 3
  650. a471 3
  651.     if (tmpBuffer) {
  652.         FreeRaster(tmpBuffer, awidth, aheight ) ;
  653.         tmpBuffer = NULL ;
  654. d473 5
  655. d567 1
  656. d569 1
  657. @
  658.  
  659.  
  660. 1.3
  661. log
  662. @*** empty log message ***
  663. @
  664. text
  665. @d1 1
  666. a1 1
  667. // $Id: window.cc 1.2 1996/08/28 20:07:00 dlorre Exp dlorre $
  668. d83 1
  669. a83 1
  670. void window::_open(MsgPort *wp, ULONG iflags, TagItem *t)
  671. d96 1
  672. a96 1
  673.     selfmsg = BOOL(!mp  && idcmp) ;
  674. d112 9
  675. a120 3
  676.         ModifyIDCMP(win, idcmp);            // idcmp is never NULL (refresh at least)
  677.         mp = win->UserPort ;
  678.         signal = 1 << mp->mp_SigBit ;
  679. @
  680.  
  681.  
  682. 1.2
  683. log
  684. @toutes les fonctions d'une ligne sont passées en INLINE dans window.h
  685. @
  686. text
  687. @d1 1
  688. a1 1
  689. // $Id$
  690. d9 1
  691. d13 1
  692. a17 1
  693. #include "locale.h"
  694. d19 7
  695. a25 7
  696. #include <cxxproto/exec.h>
  697. #include <cxxproto/graphics.h>
  698. #include <cxxproto/layers.h>
  699. #include <cxxproto/intuition.h>
  700. #include <cxxproto/gadtools.h>
  701. #include <cxxproto/utility.h>
  702. #include <cclib/debug_protos.h>
  703. d28 4
  704. d41 9
  705. a49 6
  706. lstring  ok(ocat, "_Ok", 1) ;
  707. lstring  cancel(ocat, "_Cancel") ;
  708. lstring  parent(ocat, "_Parent") ;
  709. lstring  drawer(ocat, "_Drawer:") ;
  710. lstring  file(ocat, "_File:") ;
  711. lstring  comment(ocat, "Co_mment:") ;
  712. d103 1
  713. a103 1
  714.         WA_CustomScreen, (LONG)ws->screen,
  715. d112 1
  716. a112 1
  717.         ModifyIDCMP(win, idcmp);            // idcmp is never NULL (refresh at list)
  718. d129 1
  719. d399 1
  720. a399 1
  721. short retval ;
  722. d401 21
  723. a421 19
  724.     areaBuffer = new WORD[size] ;
  725.     areaInfo = new AreaInfo ;
  726.     tmpRas = new TmpRas ;
  727.  
  728.     tmpBuffer = (UBYTE *)AllocRaster( w, h ) ;
  729.     if (!tmpBuffer)
  730.         retval = FALSE ;
  731.     else {
  732.         InitArea(areaInfo, areaBuffer, (size*2)/5);
  733.  
  734.        // docs say don't use RASSIZE in V39 but I don't know yet
  735.        // another way of doing this
  736.         InitTmpRas(tmpRas, tmpBuffer, RASSIZE( w, h )) ;
  737.         awidth = w ;
  738.         aheight = h ;
  739.         asize = size ;
  740.         rp->AreaInfo = areaInfo;
  741.         rp->TmpRas = tmpRas;
  742.         retval = TRUE ;
  743. d423 1
  744. d429 17
  745. a445 4
  746.     FreeRaster(tmpBuffer, awidth, aheight ) ;
  747.     delete tmpRas ;
  748.     delete areaInfo ;
  749.     delete [] areaBuffer ;
  750. d453 1
  751. a453 1
  752.     g->box( ws->screen->WBorLeft+20,
  753. d456 1
  754. a456 1
  755.             g->fontheight*2) ;
  756. d466 1
  757. a466 1
  758.     width = short(g->maxw-ws->screen->WBorLeft+20) ;
  759. d470 2
  760. a471 2
  761.         left = short((ws->width - width - ws->screen->WBorLeft-ws->screen->WBorRight) / 2) ;
  762.         top = short((ws->height - height - ws->winbarheight - ws->screen->WBorBottom) / 2) ;
  763. d476 24
  764. a499 1
  765. void winlist::dumplist()
  766. d501 1
  767. d504 15
  768. d520 4
  769. @
  770.  
  771.  
  772. 1.1
  773. log
  774. @Initial revision
  775. @
  776. text
  777. @d1 1
  778. d12 1
  779. d61 2
  780. a62 1
  781.                         bgbm(NULL)
  782. a181 4
  783. void window::resetidcmp()
  784. {
  785.     ModifyIDCMP(win, idcmp) ;
  786. }
  787. a302 63
  788. void window::setfunc(void (*func)(long, unsigned long, unsigned short))
  789. {
  790.     reqfunc = func ;
  791. }
  792.  
  793. void window::move(short dx, short dy)
  794. {
  795.     rectangle::move(dx, dy) ;
  796.     if (win) ChangeWindowBox(win, left, top, width, height) ;
  797. }
  798. void window::size(short dw, short dh)
  799. {
  800.     rectangle::size(dw, dh) ;
  801.     if (win) ChangeWindowBox(win, left, top, width, height) ;
  802. }
  803. void window::box(short x, short y, short w, short h)
  804. {
  805.     rectangle::box(x, y, w, h) ;
  806.     if (win) ChangeWindowBox(win, left, top, width, height) ;
  807. }
  808.  
  809. void window::limits(short wmin, short hmin, short wmax, short hmax)
  810. {
  811.     rectangle::limits(wmin, hmin, wmax, hmax) ;
  812.     if (win) WindowLimits(win, minw, minh, maxw, maxh) ;
  813. }
  814.  
  815. void window::titles(STRPTR wt, STRPTR st)
  816. {
  817.     if (win) SetWindowTitles(win, wt, st) ;
  818. }
  819.  
  820. void window::activate()
  821. {
  822.     if (win) ActivateWindow(win) ;
  823. }
  824.  
  825. void window::front()
  826. {
  827.     if (win) WindowToFront(win) ;
  828. }
  829.  
  830. void window::back()
  831. {
  832.     if (win) WindowToBack(win) ;
  833. }
  834.  
  835. void window::recessedbox(short x, short y, short w, short h)
  836. {
  837.     if (win)
  838.         DrawBevelBox(rp, x, y, w, h,
  839.         GT_VisualInfo, ws->vi,
  840.         GTBB_Recessed, TRUE,
  841.         TAG_END);
  842. }
  843.  
  844. void window::bevelbox(short x, short y, short w, short h)
  845. {
  846.     if (win)
  847.         DrawBevelBox(rp, x, y, w, h,
  848.         GT_VisualInfo, ws->vi,
  849.         TAG_END);
  850. }
  851. a386 175
  852. MenuItem *window::itemaddress( unsigned long menuNumber )
  853. {
  854.     return ItemAddress( menu, menuNumber) ;
  855. }
  856.  
  857. MenuItem *window::itemaddress(LONG m, LONG i, LONG s)
  858. {
  859.     return ItemAddress(menu, FULLMENUNUM(m, i, s)) ;
  860. }
  861.  
  862. void window::pmove(long x, long y)
  863. {
  864.     Move(rp, x, y) ;
  865. }
  866.  
  867. void window::draw(long x, long y)
  868. {
  869.     Draw(rp, x, y) ;
  870. }
  871.  
  872. void window::polydraw(long count, WORD *polyTable)
  873. {
  874.     PolyDraw(rp, count, polyTable) ;
  875. }
  876.  
  877. void window::rectfill(long xMin, long yMin, long xMax, long yMax)
  878. {
  879.     RectFill(rp, xMin, yMin, xMax, yMax) ;
  880. }
  881.  
  882. void window::eraserect(long xMin, long yMin, long xMax, long yMax )
  883. {
  884.     EraseRect(rp, xMin, yMin, xMax, yMax) ;
  885. }
  886.  
  887. void window::setapen(unsigned long pen)
  888. {
  889.     SetAPen(rp, pen) ;
  890. }
  891.  
  892. void window::setbpen(unsigned long pen)
  893. {
  894.     SetBPen(rp, pen) ;
  895. }
  896.  
  897. void window::setopen(unsigned long pen)
  898. {
  899.     SafeSetOutlinePen(rp, pen) ;
  900. }
  901.  
  902. void window::setrast(unsigned long pen)
  903. {
  904.     SetRast(rp, pen) ;
  905. }
  906.  
  907. void window::setdrmd(unsigned long drawMode)
  908. {
  909.     SetDrMd(rp, drawMode) ;
  910. }
  911.  
  912. void window::setdrpt(unsigned short pattern)
  913. {
  914.     SetDrPt(rp, pattern) ;
  915. }
  916.  
  917. void window::text( STRPTR string, unsigned long count )
  918. {
  919.     Text(rp, string, count) ;
  920. }
  921.  
  922. void window::otext( long x, long y, STRPTR string )
  923. {
  924.     pmove(x, y) ;
  925.     text(string, strlen(string)) ;
  926. }
  927.  
  928. short window::textlength(STRPTR string, unsigned long count )
  929. {
  930.     return TextLength(rp, string, count );
  931. }
  932.  
  933. unsigned long window::textfit(STRPTR string, unsigned long strLen,
  934.         struct TextExtent *textExtent, struct TextExtent *constrainingExtent,
  935.         long strDirection, unsigned long constrainingBitWidth,
  936.         unsigned long constrainingBitHeight )
  937. {
  938.     return TextFit(rp, string, strLen, textExtent, constrainingExtent,
  939.         strDirection, constrainingBitWidth, constrainingBitHeight) ;
  940. }
  941.  
  942.  
  943. void window::setfont(TextFont *font)
  944. {
  945.     SetFont( rp, font) ;
  946. }
  947. void window::printitext(IntuiText *iText, long left, long top )
  948. {
  949.     PrintIText( rp, iText, left, top) ;
  950. }
  951.  
  952. void window::drawborder( Border *border, long leftOffset, long topOffset )
  953. {
  954.     DrawBorder( rp, border, leftOffset, topOffset );
  955. }
  956.  
  957. void window::drawimage( Image *image, long leftOffset, long topOffset )
  958. {
  959.     DrawImage( rp, image, leftOffset, topOffset );
  960. }
  961.  
  962. void window::eraseimage( Image *image, long leftOffset, long topOffset )
  963. {
  964.     EraseImage( rp, image, leftOffset,  topOffset );
  965. }
  966.  
  967. int window::newregion(void)
  968. {
  969.     clipregion = NewRegion() ;
  970.     if (clipregion)
  971.         cliprect = new Rectangle ;
  972.     return (clipregion != NULL) ;
  973.  
  974. }
  975.  
  976. void window::addregion(short l, short t, short w, short h)
  977. {
  978.     cliprect->MinX = l ;
  979.     cliprect->MaxX = short(l+w) ;
  980.     cliprect->MinY = t ;
  981.     cliprect->MaxY = short(t+h) ;
  982.     OrRectRegion(clipregion, cliprect) ;
  983. }
  984.  
  985. void window::disposeregion(void)
  986. {
  987.     delete cliprect ;
  988.     DisposeRegion( clipregion );
  989. }
  990.  
  991. void window::installclip(void)
  992. {
  993.     InstallClipRegion(win->WLayer, clipregion) ;
  994. }
  995.  
  996. void window::removeclip(void)
  997. {
  998.     clipregion = InstallClipRegion(win->WLayer, NULL) ;
  999. }
  1000.  
  1001. void window::setpointer( UWORD *pointer, long height, long width,
  1002.                          long xOffset, long yOffset )
  1003. {
  1004.     SetPointer(win, pointer, height, width, xOffset, yOffset) ;
  1005. }
  1006.  
  1007. void window::clearpointer()
  1008. {
  1009.     ClearPointer(win) ;
  1010. }
  1011.  
  1012. void window::beginrefresh()
  1013. {
  1014.     GT_BeginRefresh(win) ;
  1015. }
  1016.  
  1017. void window::endrefresh(BOOL end)
  1018. {
  1019.     GT_EndRefresh(win, end) ;
  1020. }
  1021.  
  1022. void window::refreshwindowframe()
  1023. {
  1024.     RefreshWindowFrame(win) ;
  1025. }
  1026.  
  1027. a422 60
  1028. long window::areaellipse( long xCenter, long yCenter, long a, long b )
  1029. {
  1030.     return AreaEllipse( rp, xCenter, yCenter, a, b ) ;
  1031. }
  1032.  
  1033. long window::areamove( long x, long y )
  1034. {
  1035.     return AreaMove( rp, x, y );
  1036. }
  1037.  
  1038. long window::areadraw( long x, long y )
  1039. {
  1040.     return AreaDraw( rp, x, y );
  1041. }
  1042.  
  1043. long window::areaend()
  1044. {
  1045.     return AreaEnd( rp );
  1046. }
  1047.  
  1048. BOOL window::flood( unsigned long mode, long x, long y )
  1049. {
  1050.     return Flood( rp, mode, x, y );
  1051. }
  1052.  
  1053. void window::setbgrp(RastPort *brp)
  1054. {
  1055.     rp = bgrp = brp ;
  1056.     bgbm = bgrp->BitMap ;
  1057. }
  1058.  
  1059. void window::clearbgrp()
  1060. {
  1061.     rp = win->RPort ;
  1062. }
  1063.  
  1064. void window::flushbg(int x, int y, int w, int h, int mode)
  1065. {
  1066.     BltBitMapRastPort(bgbm, 0, 0, win->RPort, x, y, w, h, mode);
  1067. }
  1068.  
  1069. void window::fok(gadget *g, unsigned long classe, unsigned short code)
  1070. {
  1071.     okflag = TRUE; active = FALSE ; emode = 0 ; applique = FALSE ;
  1072. }
  1073.  
  1074. void window::fcancel(gadget *g, unsigned long classe, unsigned short code)
  1075. {
  1076.     okflag = FALSE; active = FALSE ; emode = 0 ; applique = FALSE ;
  1077. }
  1078.  
  1079. void window::fapply(gadget *g, unsigned long classe, unsigned short code)
  1080. {
  1081.     okflag = TRUE; active = FALSE ; emode = 0 ; applique = TRUE ;
  1082. }
  1083.  
  1084. void window::fname(gadget *g, unsigned long classe, unsigned short code)
  1085. {
  1086.     strcpy(sname, ((string *)g)->curstring) ;
  1087. }
  1088. d431 1
  1089. a431 1
  1090.             g->fontheight+4) ;
  1091. a448 8
  1092. }
  1093.  
  1094. void window::handlevkey(USHORT code)
  1095. {
  1096. }
  1097.  
  1098. void window::handlerawkey(USHORT code)
  1099. {
  1100. @
  1101.